<?php

namespace apiend\modules\passport\controllers;

use Yii;
use apiend\components\Controller;
use apiend\modules\passport\models\PasswordRetrieveForm;

/**
 * 帐号密码找回功能
 * 
 * @author emhome <emhome@163.com>
 * @since 2.0
 */
class ServiceController extends Controller {

    /**
     * @inheritdoc
     */
    protected function verbs() {
        return [
            '*' => ['POST'],
        ];
    }

    /**
     * @inheritdoc
     */
    protected function rules() {
        return [
            [
                'actions' => ['retrieve'],
                'allow' => true,
                'roles' => ['?'],
            ],
        ];
    }

    /**
     * 人工找回密码
     * @return mixed
     */
    public function actionRetrieve() {
        $model = new PasswordRetrieveForm();
        if (!$model->load(Yii::$app->request->post(), '')) {
            parent::error('请输入要重置的帐号手机号和短信验证码');
        }
        return $model->send();
    }

}
